<?php
if(!isset($_SESSION)){
	session_start();
}
if(empty($_SESSION['logind'])){
	echo '<script>top.location.href="./login.php";</script>';
	exit();
}
include '../setting.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
	$constr = '<?php'.chr(10);
	$tongji = $_POST['tongji'];
	$tongji = '$tongji=<<<EOT'.chr(10).$tongji.chr(10).'EOT;';
	unset($_POST['tongji']);

	$ad=$_POST['ad'];
    $ad = '$ad=<<<EOT'.chr(10).$ad.chr(10).'EOT;';
    unset($_POST['ad']);

	foreach($_POST as $key => $item){
		$constr .= '$'.$key.'=\''.$item.'\';'.chr(10);
	}
	$constr .= $ad.chr(10) .$tongji.chr(10) .'?>';

	file_put_contents('../setting.php', $constr);
	header('Content-Type:text/html;charset=utf-8');
	echo '<script>alert("保存成功！");location.href=location.href;</script>';
	exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/select-ui.min.js"></script>
 
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 100
	});
	
});
</script>

</head>

<body>
    <form action="" method="post" name="newsform">
    <div class="formbody">
		<div class="formtitle"><span>网站设置</span></div>
		<ul class="forminfo">
            <li><label>视频标题</label><input name="title" type="text" class="dfinput" value="<?php echo $title;?>"/></li>
            <li><label>腾讯视频vid</label><input name="vid" type="text" class="dfinput" value="<?php echo $vid;?>"/></li>
            <li><label>分享次数</label><input name="sharenum" type="text" class="dfinput" value="<?php echo $sharenum;?>"/>1,2,4</li>
            <li><label>暂停时间</label><input name="vtime" type="text" class="dfinput" value="<?php echo $vtime;?>"/></li>
            <li><label>公众号标题</label><input name="sharetitle" type="text" class="dfinput" value="<?php echo $sharetitle;?>"/></li>
            <li><label>返回跳转</label><input name="aftershare" type="text" class="dfinput" value="<?php echo $aftershare;?>"/></li>
            <li><label>播放结束跳转</label><input name="endurl" type="text" class="dfinput" value="<?php echo $endurl;?>"/>
            0:不做操作，url:直接跳转
            </li>
            <li><label>广告地址</label><input name="ad" type="text" class="dfinput" value="<?php echo $ad;?>"/>
              <div style="background:#f2f2f2; padding:5px;">
                广告地址填写规则： <br/>
               &lt;script src='http://u.umm6.cn/75205'&gt;&lt;/script&gt;
                <br/>
                或者(直接写地址)：<br/>
                https://www.baidu.com/
              </div>

            </li>
            <li><label>统计代码</label><textarea name="tongji" style="width:500px;height:200px;border:1px solid #a7b5bc;"><?php echo $tongji;?></textarea></li>
			<li><label>&nbsp;</label><input name="" type="submit" class="btn" value="保 存"/></li>
		</ul>
		</div>
	</form>
</body>
</html>